<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------


error_reporting(E_ERROR | E_WARNING | E_PARSE);//规避一般错误

//function connectRedis(){
//    $redis=new Redis();
//    $redis->connect("127.0.0.1",6379);
//    return $redis;
//}
function init_redis(){

    $redis=new \Redis();
    $redis->connect("127.0.0.1",6379);

    return $redis;
}

// 应用公共文件
function echoJson($code, $msg,$result=[],$page=null,$count=10) {
    header('Content-Type:application/json; charset=utf-8');

    if($page == NULL){
        $arr = array("code" => $code, "msg" => $msg, "result"=>$result);
    }else{
        $resultArr["data"] = $result;
        $resultArr["page"] = $page;
        $resultArr["count"] = $count;
        $arr = array("code" => $code, "msg" => $msg ,"result"=>$resultArr);
    }
    echo json_encode($arr, JSON_UNESCAPED_UNICODE);
    exit;
}

function gettime(){
    return date("YmdHis");
}
function getstdtime(){
    return date("Y-m-d H-i-s");
}

